<template>
	<view>
		<view > 
			<view class="head">
				<view class="detail" >
					<view v-if="hasUserInfo==true">
						<view class="detail_son1"> 账户：{{userInfo.nickname}} </view>
						<view class="detail_son2"> 余额：￥{{userInfo.money}} </view>
					</view>
					<view v-else>
						<view class="detail_son1" @tap="toLogin">请登录</view>
					</view>
				</view>
				<image src="../../static/boy.png" mode=""></image>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo : {},
				hasUserInfo:false
			}
		},
		methods: {
			toLogin(){
				uni.navigateTo({
					url: '../login/login'
				});
			}
		},
		onLoad() {
			let userInfo = {};
			let that = this;
			uni.getStorage({
			    key: 'userInfo',
			    success: function (res) {
			        // console.log(res.data);
					userInfo = res.data;
					that.userInfo = userInfo;
					that.hasUserInfo = true;
			    }
			});
		}
	}
</script>

<style lang="scss">
.head{
	background: #f3f3f3;
	display: flex;
	justify-content: space-between;
	padding: 24rpx;
	.detail{
		font-size: 42rpx;
		.detail_son1{
			margin-bottom: 30rpx;
			margin-left: 20rpx;
		}
		.detail_son2{
			margin-left: 20rpx;
		}
	}
	image{
		width: 220rpx;
		height: 220rpx;
	}
}
</style>
